<?php

declare(strict_types=1);

namespace app\api\model;

use think\facade\Request;

/**
 * 课程模型
 */
class Course extends Base
{
    protected $autoWriteTimestamp = 'datetime';

    /**
     * @param null|array|string $data
     * @return object
     */
    public static function getCourse($data = false)
    {

        if ('login' == Request::action()) {
            $course = Course::where('user_id', $data['id'])->select();
        } else
        if ('index' == Request::action()) {
            $course = Course::find($data);
        } else {
            $course = Course::field('id,name')->select();
        }

        return $course;
    }
}
